<template>
  <div class="box">
    <div class="asideR">
      <ul>
        <li><a href="#epub">综合榜</a></li>
        <li><a href="#female">女生榜</a></li>
        <li><a href="#male">男生榜</a></li>
        <li><a href="#picture">动漫榜</a></li>
      </ul>
    </div>
    <div class="Ranright">
      <ul v-for = "(value, data) of rangkingObj" :key = "data">
        <a :name="data"></a>
        <hr/>
        <li @click = "goranking(item)" v-for = "(item, index) of value" :key = "index">{{ item.title}}</li>
      </ul>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import { Indicator } from 'mint-ui'
Vue.use(Indicator)
export default{
  data () {
    return {
      rangkingObj: {}
    }
  },
  mounted () {
    this.getranking()
  },
  methods: {
    getranking () {
      return new Promise((resolve, reject) => {
        Indicator.open('加载中...')
        fetch(`/xiaoliang/rank-category`)
          .then(res => res.json())
          .then((data) => {
            console.log(data)
            this.rangkingObj = data
            resolve()
            Indicator.close()
          })
      })
    },
    goranking (item) {
      console.log(item)
      this.$router.push({path: `/rankingdetail?id=${item._id}`})
    }
  }
}
</script>
<style lang="scss">
@import '@/lib/reset.scss';
  .box{
    @include flexbox();
    @include flex-direction();
    .asideR{
      @include rect(20%, 100%);
      li{
        @include rect(100%, 1rem);
        text-align:center;
        line-height: 1rem;
      }
    }
    .Ranright{
      @include rect(80%, 100%);
      @include overflow();
      ul{
        @include rect(80%, auto);
        li{
          margin:0.3rem;
          background:#ffecf5;
          padding: 0.2rem;
          border-radius: 0.1rem;
          text-align: center;
          color:#ff869f
        }
      }
    }
  }
</style>
